package com.woniu.user.mapper;

import com.woniu.user.pojo.Fans;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 关注和粉丝表 Mapper 接口
 * </p>
 *
 * @author LiFangyu
 * @since 2023-02-15
 */
public interface FansMapper extends BaseMapper<Fans> {

    @Select("select * from t_fans where subscribe = #{userId} and be_subscribe = #{byUserToId}")
    Fans selectIsAttention(@Param("userId") String userId, @Param("byUserToId")String byUserToId);

    @Update("UPDATE t_fans SET is_deleted = 0 WHERE subscribe = #{userId} and be_subscribe = #{byUserToId} AND is_deleted = 1")
    int updateIsDeleted(@Param("userId") String userId, @Param("byUserToId")String byUserToId);

    @Update("UPDATE t_fans SET is_deleted = 1 WHERE subscribe = #{userId} and be_subscribe = #{byUserToId} AND is_deleted = 0")
    int rmAttentionByUser(@Param("userId") String userId, @Param("byUserToId")String byUserToId);
}
